<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:80:"/www/wwwroot/zaozao/public/../application/admin/view/roominfo/roominfo_list.html";i:1597927884;s:59:"/www/wwwroot/zaozao/application/admin/view/public/head.html";i:1597211856;}*/ ?>
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>支付宝生活缴费系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
	<link rel="stylesheet" href="/static/admin/css/xadmin.css">
	<!--<link rel="stylesheet" href="/static/admin/css/bootstrap.min.css">
	<link rel="stylesheet" href="/static/admin/js/bootstrap.min.js">-->
	
    <script src="/static/admin/js/jquery.min.js"></script>
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
  </head>
    <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/admin/css/area.css" />
  <body>
      
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>后台管理</cite></a>
        <a><cite>物业管理系统</cite></a>
        <a><cite>房屋管理</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  method="get" action="<?php echo url("","",true,false);?>">
            <!--<div id="addAddress" >
               <div class="address_input"><input class="address_input1" type="text" placeholder="请选择省市" id="shengshi" onClick="getProvinceBuy()" readonly="readonly"></div>
           </div>
           <div id="yzl" >
               
           </div>
            <div class="layui-input-inline" id="community_id" style="font-size: 20px;border:1px solid #ccc;width:150px" onclick="x_admin_show('添加小区','<?php echo url('address'); ?>',550,600)" >选择小区</div>
            <div class="layui-input-inline" id="group" style="font-size: 20px;border:1px solid #ccc;width:150px">选择组团</div>
            <div class="layui-input-inline" id="building" style="font-size: 20px;border:1px solid #ccc;width:150px">选择楼栋</div>
            <div class="layui-input-inline" id="unit" style="font-size: 20px;border:1px solid #ccc;width:150px">选择单元</div>
            <div class="layui-input-inline" id="room" style="font-size: 20px;border:1px solid #ccc;width:150px">选择房屋</div>-->
          <div class="layui-input-inline">
            <select name="community_id" lay-filter="community_id" id="community_id">
              <option value="">所属小区</option>
              <?php foreach($communitylist as $name): ?>
              <option value="<?php echo $name['community_id']; ?>" <?php if(isset($community_id)): if($community_id == $name['community_id']): ?>selected<?php endif; endif; ?>><?php echo $name['community_name']; ?></option>
              <?php endforeach; ?>
            </select>
          </div>
          <!--<div class="layui-input-inline">
            <select name="group" id="group" lay-filter="group">
              <option value="">组团</option>
              <?php if(isset($groups)): foreach($groups as $gro): ?>
                <option value="<?php echo $gro; ?>" <?php if(isset($group)): if($gro == $group): ?>selected<?php endif; endif; ?>><?php echo $gro; ?></option>
              <?php endforeach; endif; ?>
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="building" id="building" lay-filter="building">
              <option value="">所属楼栋</option>
              <?php if(isset($buildings)): foreach($buildings as $build): ?>
                <option value="<?php echo $build; ?>" <?php if(isset($building)): if($build == $building): ?>selected<?php endif; endif; ?>><?php echo $build; ?></option>
              <?php endforeach; endif; ?>
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="unit" id="unit"  lay-filter="unit">
              <option value="">所属单元</option>
              <?php if(isset($units)): foreach($units as $uni): ?>
                <option value="<?php echo $uni; ?>" <?php if(isset($unit)): if($uni == $unit): ?>selected<?php endif; endif; ?>><?php echo $uni; ?></option>
              <?php endforeach; endif; ?>
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="room" id="room">
              <option value="">所属房间号</option>
              <?php if(isset($rooms)): foreach($rooms as $roo): ?>
                <option value="<?php echo $roo; ?>" <?php if(isset($room)): if($roo == $room): ?>selected<?php endif; endif; ?>><?php echo $roo; ?></option>
              <?php endforeach; endif; ?>
            </select>
          </div>-->
          
          
          <input class="layui-input" placeholder="房屋查询" name="address" value="<?php if(isset($address)): ?><?php echo $address; endif; ?>">
          <input class="layui-input" placeholder="姓名" name="owner_name" value="<?php if(isset($owner_name)): ?><?php echo $owner_name; endif; ?>">
          <input class="layui-input" placeholder="电话" name="owner_phone" value="<?php if(isset($owner_phone)): ?><?php echo $owner_phone; endif; ?>">
          <div class="layui-input-inline">
            <select name="status">
              <option value="">同步状态</option>
              <option value="1" <?php if(isset($status)): if($status == '1'): ?>selected<?php endif; endif; ?>>已同步</option>
              <option value="2" <?php if(isset($status)): if($status == '2'): ?>selected<?php endif; endif; ?>>未同步</option>
            </select>
          </div>
          <input class="layui-input" placeholder="支付宝房屋编号" name="out_room_id" value="<?php if(isset($out_room_id)): ?><?php echo $out_room_id; endif; ?>">
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
        <?php if(\think\Session::get('usertype')=="0"): ?>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        
        <button class="layui-btn " onclick="x_admin_show('添加小区','<?php echo url('roominfoAdd'); ?>',550,600)"><i class="layui-icon"></i>添加房屋</button>
        <?php endif; ?>
        <button class="layui-btn layui-btn-danger" onclick="x_admin_show('批量导入','<?php echo url('roomExcel'); ?>',600,400)"><i class="layui-icon"></i>批量导入</button>
        <button class="layui-btn" onclick="roomExportExcel('<?php echo $export; ?>')"><i class="layui-icon"></i>批量导出</button>
        <button class="layui-btn layui-btn-danger" onclick="roomUpload()"><i class="layui-icon"></i>批量同步</button>
        <span class="x-right" style="line-height:40px">共有数据：<?php echo $number; ?> 条</span>
      </xblock>
      <table class="layui-table" id="table">
        <thead  style="text-align:center;">
          <tr>
            <th style="width: 4%;text-align:center;">
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th style="text-align: center; font-size: 16px;">小区名称</th>
            <!--<th style="text-align: center; font-size: 16px;">支付宝房屋编号</th>
            <th style="text-align: center; font-size: 16px;">组团</th>
            <th style="text-align: center; font-size: 16px;">楼栋</th>
            <th style="text-align: center; font-size: 16px;">单元</th>
            <th style="text-align: center; font-size: 16px;">房号</th>-->
            <th style="text-align: center; font-size: 16px;">完整门牌</th>
            <th style="text-align: center; font-size: 16px;">业主姓名</th>
            <th style="text-align: center; font-size: 16px;">业主电话</th>
            <th style="text-align: center; font-size: 16px;">面积</th>
            <th style="text-align: center; font-size: 16px;">单价</th>
            <th style="text-align: center; font-size: 16px;">费用</th>
           
            <th style="text-align: center; font-size: 16px;">同步状态</th>
            <!--<th style="text-align: center; font-size: 16px;">入住时间</th>
            <th style="text-align: center; font-size: 16px;">积分</th>-->
            <th style="text-align: center; font-size: 16px;">操作</th>
          </tr>
        </thead>
        <tbody style="text-align:center;">
          <?php foreach($list as $val): ?>
          <tr>
            <td style="text-align: center;">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='<?php echo $val['id']; ?>'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td style="text-align: center;"><?php echo $val['community_id']; ?></td>
            <!--<td style="text-align: center;"><?php echo $val['out_room_id']; ?></td>
            <td style="text-align: center;"><?php echo $val['group']; ?></td>
            <td style="text-align: center;"><?php echo $val['building']; ?></td>
            <td style="text-align: center;"><?php echo $val['unit']; ?></td>
            <td style="text-align: center;"><?php echo $val['room']; ?></td>-->
            <td style="text-align: center;"><?php echo $val['address']; ?></td>
            <td style="text-align: center;"><?php echo $val['owner_name']; ?></td>
            <td style="text-align: center;"><?php echo $val['owner_phone']; ?></td>
            <td style="text-align: center;"><?php echo $val['area']; ?></td>
            <td style="text-align: center;"><?php echo $val['price']; ?></td>
            <td style="text-align: center;"><?php echo $val['cost']; ?></td>
            <td style="text-align: center;">
              <?php if($val['status'] == 1): ?>
                已同步
              <?php else: ?>
                未同步
              <?php endif; ?>
            </td>
            <!--<td style="text-align: center;"><?php echo $val['time']; ?></td>
            <td style="text-align: center;"><?php echo $val['point']; ?></td>-->
            <td style="text-align: center;">
                <a title="编辑"  onclick="x_admin_show('编辑','<?php echo url('admin/Roominfo/roominfoEdit'); ?>?id=<?php echo $val['id']; ?>',550,600)" href="javascript:;">
                  <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="添加账单"  onclick="x_admin_show('添加账单','<?php echo url('billAdd'); ?>?id=<?php echo $val['id']; ?>',800,600)" href="javascript:;" id="billadd<?php echo $val['id']; ?>">
                  <i class="layui-icon">&#xe608;</i>
                </a>
                
                
               <?php if(\think\Session::get('usertype')=="0"): ?>
                <a title="账单查询"  onclick="x_admin_show('账单查询','<?php echo url('billquery'); ?>?id=<?php echo $val['id']; ?>',800,500)" href="javascript:;">
                <img src="/static/index/images/bill.png" style="width:16px;height:16px"/>
              </a>
                <!--<a title="删除" onclick="roominfoDelId('<?php echo $val['id']; ?>', '<?php echo $val['id']; ?>')" href="javascript:;" id="<?php echo $val['id']; ?>">
                    <i class="layui-icon">&#xe640;</i>
                  </a>-->
               <?php endif; ?>
            </td>
          </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
      <div class="page">
        <div>
            <?php echo $roomlist->render(); ?>
        </div>
      </div>

    </div>
    <script>
    var proStr=<?php echo $proStr; ?>;
    function getProvinceBuy(){
        console.log(proStr);
        $("body .dqld_div").remove();
        var province=eval(proStr);
        var newStr=new Array();
        newStr.push("<div class=\"dqld_div\" style=\"\"><ul>");
        for(var i=0,psize=province.length;i<psize;i++){
        		province[i].NAME;
        		newStr.push("<li onclick=\"getCityBuy("+i+")\">"+province[i].NAME+"</li>");
        }
        newStr.push("</ul></div>");
        $("#yzl").append(newStr.join(""));
    }

function getCityBuy(val){
	var province=eval(proStr);
	var city=eval(province[val].ITEMS);
	var newStr=new Array();
	newStr.push("<div class=\"dqld_div\"><ul>");
	newStr.push("<li onclick=\"getProvinceBuy()\" style=\"background-color:#808080;\">"+province[val].NAME+"</li>");
	for(var j=0,csize=city.length;j<csize;j++){
		newStr.push("<li onclick=\"getAreaBuy("+j+","+val+")\"  style=\"padding-left:20px;\">"+city[j].NAME+"</li>");
	}
	newStr.push("</ul></div>");
	$("body .dqld_div").remove();
	$("#yzl").append(newStr.join(""));
}

function getAreaBuy(val,val1){
	var province=eval(proStr);
	var city=eval(province[val1].ITEMS);
	var area=eval(city[val].ITEMS);
	var newStr=new Array();
	newStr.push("<div class='dqld_div'><ul>");
	newStr.push("<li onclick=\"getProvinceBuy()\" style=\"background-color:#999999;\">"+province[val1].NAME+"</li>");
	newStr.push("<li onclick=\"getCityBuy("+val1+")\" style=\"background-color:#ccc;padding-left:10px;\">"+city[val].NAME+"</li>");
	for(var t=0,asize=area.length;t<asize;t++){
		area[t].NAME;
		newStr.push("<li  style=\"padding-left:25px;\" onclick=\"getallArea("+val1+","+val+","+t+")\">"+area[t].NAME+"</li>");
	}
	newStr.push("</ul></div>");
	if(asize==0){
		var allarea=province[val1].NAME+city[val].NAME;
		$("#shengshi").attr({"SS":province[val1].NAME,"SQ":city[val].NAME,"XS":""});
		$("#shengshi").val(allarea);
		$("body .dqld_div").remove();
	}
	else{
		$("body .dqld_div").remove();
		$("#yzl").append(newStr.join(""));
	}
}

function getallArea(val,val1,val2){
	var province=eval(proStr);
	var city=eval(province[val].ITEMS);
	var area=eval(city[val1].ITEMS);
	var allarea=province[val].NAME+city[val1].NAME+area[val2].NAME;
	$("#shengshi").attr({"SS":province[val].NAME,"SQ":city[val1].NAME,"XS":area[val2].NAME});
	$("#shengshi").val(allarea);
	$("body .dqld_div").remove();
}
/*地区联动*/
</script>
   
    <script>

      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

       //删除
      function roominfoDelId(id, doc){
        if(confirm('删除后无法恢复，确定要删除吗?')) 
        { 
          var url = "<?php echo url('roominfoDelId'); ?>?id=" + id
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 
      //批量删除
      function delAll () {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        layer.confirm('你确定要删除这'+ count + '项吗', function(){
          $.post('<?php echo url("admin/Roominfo/roominfoDel"); ?>', {id: str}, function(r){
            if(r.info){
              layer.msg(r.info);
                setTimeout(function (){
                 
                	window.location.reload();
                }, 700)
            }else{
              layer.msg(r.error)
               setTimeout(function (){
                 
                	window.location.reload();
                }, 700)
            }
          })
        })
      }
      //批量同步
      function roomUpload(){
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        //window.location.href="<?php echo url('roomUpload'); ?>?id="+str;
        layer.confirm('你确定要同步这'+ count + '项吗', function(){
          $.post('<?php echo url("admin/Roominfo/roomUpload"); ?>', {id: str}, function(r){
            if (r.info) {
              layer.msg(r.info)
              setTimeout(function (){
                	window.location.reload();
                }, 700)
            }else{
              layer.msg(r.error)
              setTimeout(function (){
                	window.location.reload();
                }, 700)
            }
          },"json")
        })
      }

      //批量导出
      function roomExportExcel(exportid){
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        var url = "<?php echo url('admin/Roominfo/roomExportExcel'); ?>?id=" + str +'&export=' + exportid
        layer.open({
          type: 2,
          title: '批量导出房屋',
          shadeClose: true,
          shade: 0.8,
          area: ['80%', '95%'],
          content: url //iframe的url
        }); 
      }
      
    </script>
    <!-- 搜索 -->
    <script>
      layui.use(['form'], function() {
          var form = layui.form
          form.on('select(community_id)', function(f){
              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {community_id: f.value, type: 1}, function(data) {
                  $('#group').html("")
                  var option = "<option value=''>所有组团</option>"
                  $('#group').append(option)
                  for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#group').append(option)
                  }
                  
                  form.render('select')
              })
              
                $('#community_id').data('community_id', f.value)
                
          })

          form.on('select(group)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community
              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
                  $('#building').html("")
                  var option = "<option value=''>所有楼栋</option>"
                  $('#building').append(option)
                  for (var i = 0; i < data.length; i++) {
                      option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                      $('#building').append(option)
                  }
                  $('#group').data('group', f.value)
                  form.render('select')
              })
          })
  
          form.on('select(building)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community

              var data_group = $('#group').data('group')
              var get_group = "<?php if (isset($group)) { echo $group;}?>"
              var group = typeof data_group === 'undefined' ? get_group : data_group

              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
              $('#unit').html("")
              var option = "<option value=''>所有单元</option>"
              $('#unit').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#unit').append(option)
              }
              $('#building').data('building', f.value)
              form.render('select')
              })
          })
  
          form.on('select(unit)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community

              var data_group = $('#group').data('group')
              var get_group = "<?php if (isset($group)) { echo $group;}?>"
              var group = typeof data_group === 'undefined' ? get_group : data_group

              var data_building = $('#building').data('building')
              var get_building = "<?php if (isset($building)) { echo $building;}?>"
              var building = typeof data_building === 'undefined' ? get_building : data_building
      
              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
              $('#room').html("")
              var option = "<option value=''>所有房间</option>"
              $('#room').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#room').append(option)
              }
              $('#unit').data('unit', f.value)
              form.render('select')
              })
          })
  
      })
  </script>

    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>

  </body>

</html>